package com.tbit.uqbike.client.constant.enums;

/**
 * 扫码来源，前端orderSource请求头
 *
 * @author <a href="mailto:zheng.zebiao@tbit.com.cn">zb</a>
 * @since 2024/9/3
 */
public enum SourceType {
    /**
     * 微信小程序
     */
    WECHAT(3, "wechat"),
    /**
     * 支付宝小程序
     */
    ALIPAY(4, "alipay"),
    /**
     * 未知
     */
    UNKNOWN(null, ""),
    ;

    public final Integer code;
    public final String name;
    SourceType(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static SourceType getByName(String name) {
        for (SourceType sourceType : values()) {
            if (sourceType.name.equals(name)) {
                return sourceType;
            }
        }
        return UNKNOWN;
    }

    public static SourceType getByCode(Integer code) {
        for (SourceType sourceType : values()) {
            if (sourceType.code.equals(code)) {
                return sourceType;
            }
        }
        return UNKNOWN;
    }
}
